import axios from 'axios';
import Qs from 'qs';
import env from '../config/env';

let util = {

};
util.title = function(title) {
    title = title ? title + ' - Home' : 'iView project';
    window.document.title = title;
};

const ajaxUrl = env === 'development' ?
    'http://47.95.249.122/api' :
    env === 'production' ?
    'https://www.url.com' :
    'https://debug.url.com';

util.ajax = axios.create({
    baseURL: ajaxUrl,
    timeout: 30000,
    headers: {'token': 'token111'},
    transformRequest: [function (data) {
        //允许在向服务器发送前，修改请求数据
        console.log(Qs.stringify(data));
        return Qs.stringify(data);
    }],
    responseType: 'json'
});

export default util;